using System;
using System.Data;
using System.Collections.Generic;

namespace shfa.snomtastic.data.business
{
    public partial class UserController
    {
		private UserInfo ObjectFromDataRow(DataRow dr)
        {
            if (dr != null)
            {
				UserInfo obj = new UserInfo();
				obj.UserId = dr.Field<Guid>("UserId"); 
				obj.GroupId = (dr["GroupId"] != DBNull.Value) ? dr.Field<Guid>("GroupId") : Guid.Empty; 
				obj.UserName = dr.Field<String>("UserName"); 
				obj.Password = (dr["Password"] != DBNull.Value) ? dr.Field<String>("Password") : string.Empty; 
				obj.PasswordUpdate = (dr["PasswordUpdate"] != DBNull.Value) ? dr.Field<DateTime>("PasswordUpdate") : DateTime.MinValue; 
				obj.PasswordUpdateAD = (dr["PasswordUpdateAD"] != DBNull.Value) ? dr.Field<DateTime>("PasswordUpdateAD") : DateTime.MinValue; 
				obj.CreatedDate = dr.Field<DateTime>("CreatedDate"); 
				obj.UpdatedDate = dr.Field<DateTime>("UpdatedDate"); 
				obj.LastAccessDate = (dr["LastAccessDate"] != DBNull.Value) ? dr.Field<DateTime>("LastAccessDate") : DateTime.MinValue; 
				return obj;
            }
            return null;
        }

        private List<UserInfo> ListFromDataTable(DataTable dt)
        {
            List<UserInfo> lst = new List<UserInfo>();

            foreach (DataRow dr in dt.Rows)
            {
                lst.Add(ObjectFromDataRow(dr));
            }

            return lst;
        }
    }
}
